package net.guerlab.credits.usercredits.entity;

import java.io.Serializable;
import java.math.BigDecimal;

import net.guerlab.credits.creditsoption.entity.CreditsOption;

/**
 * 用户积分
 * 
 * @author guer
 *
 */
public class UserCredits implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    private String userId;

    /**
     * 积分ID
     */
    private Integer creditId;

    /**
     * 积分数量
     */
    private BigDecimal number;

    /**
     * 积分设置项
     */
    private CreditsOption creditsOption;

    /**
     * 获取用户ID
     * 
     * @return 用户ID
     */
    public final String getUserId() {
        return userId;
    }

    /**
     * 设置用户ID
     * 
     * @param userId
     *            用户ID
     */
    public final void setUserId(String userId) {
        this.userId = userId;
    }

    /**
     * 获取积分ID
     * 
     * @return 积分ID
     */
    public final Integer getCreditId() {
        return creditId;
    }

    /**
     * 设置积分ID
     * 
     * @param creditId
     *            积分ID
     */
    public final void setCreditId(Integer creditId) {
        this.creditId = creditId;
    }

    /**
     * 获取积分数量
     * 
     * @return 积分数量
     */
    public final BigDecimal getNumber() {
        return number;
    }

    /**
     * 设置积分数量
     * 
     * @param number
     *            积分数量
     */
    public final void setNumber(BigDecimal number) {
        this.number = number;
    }

    /**
     * 获取积分设置项
     * 
     * @return 积分设置项
     */
    public final CreditsOption getCreditsOption() {
        return creditsOption;
    }

    /**
     * 设置积分设置项
     * 
     * @param creditsOption
     *            积分设置项
     */
    public final void setCreditsOption(CreditsOption creditsOption) {
        this.creditsOption = creditsOption;
    }

    @Override
    public String toString() {
        return "UserCredits [userId=" + userId + ", creditId=" + creditId + ", number=" + number + ", creditsOption="
                + creditsOption + "]";
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((creditId == null) ? 0 : creditId.hashCode());
        result = prime * result + ((userId == null) ? 0 : userId.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        UserCredits other = (UserCredits) obj;
        if (creditId == null) {
            if (other.creditId != null) {
                return false;
            }
        } else if (!creditId.equals(other.creditId)) {
            return false;
        }
        if (userId == null) {
            if (other.userId != null) {
                return false;
            }
        } else if (!userId.equals(other.userId)) {
            return false;
        }
        return true;
    }
}